home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / Profiling with CodeWarrior < prev   
Encoding:
Text File  |  1996-08-16  |  5.4 KB  |  100 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Profiling with CodeWarrior
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. -------------------------
  11. • Building ODFCWProfilerLib
  12. • Profiling the ODF Shared Library
  13. • Profiling ODF Static Libraries
  14. • Automatic Modification of ODF Libraries
  15. • Modifying Your Part
  16. • Enabling Profiling
  17.  
  18. It is possible to use the performance profiling tools included in the Metrowerks CodeWarrior toolset to generate performance measurements for PowerPC OpenDoc parts built with ODF.  It is not currently possible to profile 68k parts built with ODF. This document describes the CWPPCProfiler library and the steps necessary to configure profiling for an ODF part. Detailed information on the Metrowerks CodeWarrior Profiler can be found in the CodeWarrior documentation.
  19.  
  20.  
  21. Building ODFCWProfilerLib
  22.  
  23. Profiling of ODF-based parts is based on the ODFCWProfilerLib shared library. This library is not provided in its built state. To build the library, open the CodeWarrior project at the path “ODFDev:ODF:Tools:Mac:CWPPCProfiler:ODFCWProfilerLib.π”. Build the library by selecting “Make” from the “Project” menu in CodeWarrior. The built library will be created as “ODFDev:ODF:Tools:Mac:ODFCWProfilerLib.PPC”.
  24.  
  25.  
  26. Profiling the ODF Shared Library
  27.  
  28. During the process of profiling your part editor, you may find it useful to generate profiler data for the ODF shared library.  Profiling the shared libary requires the following modifications:
  29.  
  30. 1. Open the “ODFDev:ODF:SLPPCDebug:ODFLibrary.π” project in CodeWarrior. 
  31.  
  32. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  33.  
  34. 3. Add the ODFCWProfilerLib.PPC library you built earlier to the ODFLibrary project. Rebuild the ODFLibrary and replace the version in your Extensions folder with the new version.
  35.  
  36.  
  37. Profiling ODF Static Libraries
  38.  
  39. During the process of profiling your part editor, you may find it useful to generate profiler data for one or more of the ODF static libraries. Profiling the static libraries requires the following modifications to each of the static libraries (Foundation, OS, Framework) that you wish to profile:
  40.  
  41. 1. Open the  project in CodeWarrior. 
  42.  
  43. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  44.  
  45. 3. Rebuild the library.
  46.  
  47.  
  48. Automatic Modification of ODF Libraries
  49.  
  50. ODF includes an AppleScript that automatically enables profiling of all static ODF libraries and, optionally, the ODF shared library. If you want to automatically enable or disable profiling of the ODF libraries, execute the script at “ODFDev:ODF:Tools:Mac:Enable CWPPCProfiler”.  Usually, you will want to profile your part, not the ODF libraries, so this script may not apply.
  51.  
  52.  
  53. Modifying Your Part
  54.  
  55. To enable profiling of your part, do the following:
  56.  
  57. 1. Open your part’s  project in CodeWarrior. 
  58.  
  59. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  60.  
  61. 3. Add the ODFCWProfilerLib.PPC library you built earlier to your project. 
  62.  
  63. 4. Rebuild and install your part.
  64.  
  65.  
  66. Enabling Profiling
  67.  
  68. Once the appropriate projects and libraries have been configured to profile, you must explicitly enable profiling of the code you want to measure. The header file “FWProfiler.h” contains declarations and comments relevant to profiling (the Metrowerks profiler library should not be called directly). All methods are described below:
  69.  
  70. FW_ProfilerSetStatus: Pass this function a value of TRUE to turn profiling on and a value of FALSE to turn profiling off. 
  71.  
  72. FW_ProfilerGetStatus: Returns TRUE if profiling is on, FALSE if profiling is off.
  73.  
  74. FW_ProfilerSetDumpFile:  Optionally call this method and provide a path, as a length-prefixed pascal string, indicating where the profiling information should be dumped. If this method is not called, profiler data will be dumped into a file called “ODFProfiler Dump” at the root of the startup disk. If the dump file already exists when a dump occurs, the first unique number beginning at 1 will be added to the file name.
  75.  
  76. FW_ProfilerUseDefaultDumpFile: Calling this method resets the dump file location to its default of “ODFProfiler Dump” at the root of the boot volume.
  77.  
  78. FW_ProfilerDump: Dumps the profiler buffer into the current dump file. Calling this method does not clear the profiler buffer.
  79.  
  80. FW_ProfilerClear: Clears the profiler buffer. This method does not affect the on/off status of the profiler.
  81.  
  82. An example of how to use these methods follows:
  83.  
  84.      #ifndef FWPROFILER_H
  85.      #include "FWProfiler.h"  // add at beginning of source files that
  86.      #endif                   // call FW_Profiler methods
  87.  
  88.      void CMyPart::SomeMethod()
  89.      {
  90.         FW_ProfilerSetDumpFile("\pHD:MyPartDumpFile");
  91.         FW_ProfilerSetStatus(TRUE);
  92.              ... call subroutines ...
  93.         FW_ProfilerDump();
  94.         FW_ProfilerSetStatus(FALSE);
  95.      }
  96.  
  97. Consult the Metrowerks documention for information on how to view and interpret profiler dump files.         
  98.  
  99. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  100. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.